package cn.ffcs.tmp.service;

import java.util.Date;

import javax.servlet.ServletContext;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import cn.ffcs.base.service.BaseService;
import cn.ffcs.security.model.User;
import cn.ffcs.tmp.dao.AnnexDAO;
import cn.ffcs.tmp.model.Annex;
import cn.ffcs.util.context.ApplicationContextUtil;

/**
 * 
 * 附件服务层实现<br/> <table>
 * <tr>
 * <td>负责人/principal: </td>
 * <td colspan="2">pany</td>
 * <tr>
 * <td>修改记录/revision:</td>
 * <td colspan="2"></td>
 * </tr>
 * <tr>
 * <td>日期:</td>
 * <td>修改人:</td>
 * <td>修改说明:</td>
 * </tr>
 * <tr>
 * <td></td>
 * <td></td>
 * <td></td>
 * </tr>
 * </table>
 * @author pany
 * @version $Id$
 */
public class AnnexService<A extends Annex> extends BaseService<A> implements
        IAnnexService<A>
{
    /**
     * 新增或修改操作
     * @param baseEntity
     */
    public void saveOrUpdate(A baseEntity,WebApplicationContext ctx)
    {
        if (baseEntity != null)
        {
            AnnexDAO baseDAO=(AnnexDAO)ctx.getBean("AnnexDAO");
            if (baseEntity.getId() == null || baseEntity.getId() == 0)
            {   
//                //设置操作人
//                baseEntity.setCreator("listener");
                //设置有效时间
                baseEntity.setBegin(baseDAO.getCurrSysdate());
                Long l=Long.valueOf("9783941568000");
                Date end=new Date(l);
                baseEntity.setEnd(end);
                //保存数据
                baseDAO.save(baseEntity);
            }
            else
            {
                baseDAO.update(baseEntity);
            }
        }
    }
}
